//
//  XFCaseFileViewController.m
//  名医通
//
//  Created by mr.zhou on 16/7/11.
//  Copyright © 2016年 mr.zhou. All rights reserved.
//

#import "XFCaseFileViewController.h"
#import "XFAddCaseViewController.h"
#import "XFCaseFileModel.h"
#import "XFCaseFileCell.h"


@interface XFCaseFileViewController () <UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UIImageView *iconVIew;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *idCardLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneNumberLabel;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (nonatomic,strong) NSMutableArray *caseList;


@end

@implementation XFCaseFileViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tableView.delegate = self;
    
    self.tableView.dataSource = self;
    
    
    
    UINib *nib = [UINib nibWithNibName:@"XFCaseFileCell" bundle:nil];
    
    [self.tableView registerNib:nib forCellReuseIdentifier:@"caseFile"];
                  
                  
    
}

#pragma mark - datasource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    XFCaseFileCell *cell = (XFCaseFileCell *)[tableView dequeueReusableCellWithIdentifier:@"caseFile" forIndexPath:indexPath];

    cell.caseFile = self.caseList[indexPath.row];
    
    return cell;

}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.caseList.count;

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    

}





#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    XFAddCaseViewController *addVC = segue.destinationViewController;
    
    addVC.didAddedCaseBlock = ^(XFCaseFileModel *caseModel) {
    
        
        [self.caseList addObject:caseModel];
        
        [self.tableView reloadData];
    
    };
    
}

#pragma mark - 懒加载
-(NSMutableArray *)caseList {

    if (_caseList == nil) {
    
        _caseList = [NSMutableArray array];
    }
    return _caseList;
}


@end
